package com.to.aboomy.bannersample.util;

import com.bumptech.glide.util.LogUtil;
import com.to.aboomy.banner.BannerViewPager;
import ohos.agp.components.Component;

/**
 * @since 2021-07-27
 */
public class ZoomOutSlideTransformer implements BannerViewPager.PageTransformer {

    private static final float MIN_SCALE = 0.85f;

    @Override
    public void transformerPage(BannerViewPager.PageType pageType, Component page, float offset, float offsetPixels) {

        float scale = 0.7f;
        switch (pageType) {
            case PREVIOUS:
                if (offsetPixels <= 0) {
                    scale = 0.7f + offset * 0.5f;
                    if (scale > 1) {
                        scale = 1;
                    }
                }
                break;
            case CURRENT:
                scale = 1 - offset * 0.5f;
                if (scale < 0.7f) {
                    scale = 0.7f;
                }
                break;
            case NEXT:
                if (offsetPixels >= 0) {
                    scale = 0.7f + offset * 0.5f;
                    if (scale > 1) {
                        scale = 1;
                    }
                }
                break;
        }
        page.setScale(scale, scale);
        System.out.println(scale+"======scale====="+pageType);
    }
}

